package com.example.designpatterns.chain;

import org.junit.Test;

/**
 * 责任链模式de测试
 */


public class CTest1 {
    @Test
    public void cT1(){
        Leader t1 = new LeaderT1("tt1");
        Leader t2 = new LeaderT2("tt2");
        Leader t3  = new LeaderT3("tt3");
        //t1.setSuccessor(t2);//t1的后续是t2
        //t2.setSuccessor(t3);//t2的后续是t3
        //创建责任链对象
        ChainLeader c = new ChainLeader();
        c.addLeader(t1);
        c.addLeader(t2);
        c.addLeader(t3);


        LeaveNode leaveNode1 = new LeaveNode("qq",1);
        t1.handleRequest(leaveNode1);

        LeaveNode leaveNode2 = new LeaveNode("ww",4);
        t1.handleRequest(leaveNode2);

        LeaveNode leaveNode3 = new LeaveNode("ee",11);
        t1.handleRequest(leaveNode3);

        LeaveNode leaveNode4 = new LeaveNode("rr",16);
        t1.handleRequest(leaveNode4);
    }
}
